<?php
echo $this->session->flash();
if (!empty($payableList)) {
    $this->Paginator->options(array(
        'update' => '#divUpdate',
        'evalScripts' => true,
    ));
}
//pr($payableList);
?>
<div class="file" id="List">
    <table width="100%" border="0" cellspacing="1" cellpadding="2" class="list">
        <tr class="heading" style="background: #708089;">
            <th><?php echo __('S.NO'); ?></th>
            <th><?php echo $this->Paginator->sort('e_name', __('E_NAME',true)); ?></th>
            <th><?php echo $this->Paginator->sort('c_name', __('C_NAME',true)); ?></th>
            <th><?php echo $this->Paginator->sort('payee_id_proof_no', __('PAYEE_ID_PROOF_NO',true)); ?></th>
            <th><?php echo $this->Paginator->sort('course_head_count', __('COURSE_HEAD_COUNT',true)); ?></th>
            <th><?php echo $this->Paginator->sort('total_fee_income', __('TOTAL_INCOME',true)); ?></th>
            <th><?php echo $this->Paginator->sort('amount', __('AMOUNT_PAYABLE',true)); ?></th>
            <th><?php echo __('INCOME_SPLITE_REMARKS'); ?></th>
            <th><?php echo __('COURSE_REMARKS'); ?></th>
            <th><?php echo $this->Paginator->sort('contract_sheet_no', __('CONTR_SHEET_NO',true)); ?></th>
            <th><?php echo __('ACTION'); ?></th>
        </tr>
        <?php
        if (isset($payableList) && count($payableList) > 0) {
            $i = 0;
            foreach ($payableList as $arrayDetail) {
                ?>
                <tr class="<?php echo (($i % 2) == 0) ? 'even' : 'odd'; ?>">
                    <td>&nbsp;<?php echo $i + 1 ?></td>
                    <td>&nbsp;<?php 
                    //echo $arrayDetail['Payable']['e_name']; 
                    echo $this->Html->link(
                                $arrayDetail['Payable']['e_name'], '#', array(
                                'target' => '_blank',
                                'escape' => false,
                                'onClick' => "window.open('".$this->Html->url(array(
                                    'controller' => 'reports',
                                    'action' => 'payment_history/'.$arrayDetail['Payable']['payee_id_proof_no'],
                                ))."', 'windowname','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=500'); return false;"
                            ));
                    ?></td>
                    <td>&nbsp;<?php echo $arrayDetail['Payable']['c_name']; ?></td>
                    <td>&nbsp;<?php echo $arrayDetail['Payable']['payee_id_proof_no']; ?></td>
                    <td class="integer">&nbsp;<?php echo $arrayDetail['Payable']['course_head_count']; ?></td>
                    <td class="integer">&nbsp;<?php echo $arrayDetail['Payable']['total_fee_income']; ?></td>
                    <td class="integer">&nbsp;<?php echo $arrayDetail['Payable']['amount_payable']; ?></td>
                    <td class="textData">&nbsp;<?php echo $arrayDetail['Payable']['income_splite_remarks']; ?></td>
                    <td class="textData">&nbsp;<?php echo $arrayDetail['Payable']['course_remarks']; ?></td>
                    <td class="textData">&nbsp;<?php echo $arrayDetail['Payable']['contract_sheet_no']; ?></td>
                    <td><?php
                    if($batchListData['BatchList']['checker'] == 0){
                        if(!$roleId){
                            if($arrayDetail['Payable']['on_hold'] == 0){
                                echo $this->Html->link(
                                    $this->Html->image('icons/16/cancel_request.png'), array(
                                        'controller' => 'payrolls',
                                        'action' => 'hold_payment', $arrayDetail['Payable']['id'], $arrayDetail['Payable']['batch_list_id']
                                    ), array(
                                        //'update' => '#divUpdate',
                                        'alt' => __('HOLD_PAYMENT', true),
                                        'title' => __('HOLD_PAYMENT', true),
                                        'escape' => false,
                                        //'before' => $this->Js->get('#divUpdate')->effect('fadeOut'),
                                        //'success' => $this->Js->get('#divUpdate')->effect('fadeIn'),
                                        'confirm' => 'Are you sure to hold payment?'
                                    )
                                );
                            } else {
                                echo $this->Html->link(
                                    $this->Html->image('icons/16/reply.png'), array(
                                        'controller' => 'payrolls',
                                        'action' => 'revert_hold_payment', $arrayDetail['Payable']['id'], $arrayDetail['Payable']['batch_list_id']
                                    ), array(
                                        //'update' => '#divUpdate',
                                        'alt' => __('REVERT_HOLD_PAYMENT', true),
                                        'title' => __('REVERT_HOLD_PAYMENT', true),
                                        'escape' => false,
                                        //'before' => $this->Js->get('#divUpdate')->effect('fadeOut'),
                                        //'success' => $this->Js->get('#divUpdate')->effect('fadeIn'),
                                        'confirm' => 'Are you sure to revert payment hold?'
                                    )
                                );
                            }
                        }else{
                            if($showBatchPaymentHoldURL){
                                if($arrayDetail['Payable']['on_hold'] == 0){
                                    echo $this->Html->link(
                                        $this->Html->image('icons/16/cancel_request.png'), 
                                        array(
                                            'controller' => 'payrolls',
                                            'action' => 'hold_payment', $arrayDetail['Payable']['id'], $arrayDetail['Payable']['batch_list_id']
                                        ), 
                                        array(
                                            //'update' => '#divUpdate',
                                            'alt' => __('HOLD_PAYMENT', true),
                                            'title' => __('HOLD_PAYMENT', true),
                                            'escape' => false,
                                            //'before' => $this->Js->get('#divUpdate')->effect('fadeOut'),
                                            //'success' => $this->Js->get('#divUpdate')->effect('fadeIn'),
                                            'confirm' => 'Are you sure to hold payment?'
                                        )
                                    );
                                }
                            }
                            if($showBatchRevertPaymentHoldURL){
                                if($arrayDetail['Payable']['on_hold'] != 0){
                                    echo $this->Html->link(
                                        $this->Html->image('icons/16/reply.png'), 
                                        array(
                                            'controller' => 'payrolls',
                                            'action' => 'revert_hold_payment', $arrayDetail['Payable']['id'], $arrayDetail['Payable']['batch_list_id']
                                        ), 
                                        array(
                                            'alt' => __('REVERT_HOLD_PAYMENT', true),
                                            'title' => __('REVERT_HOLD_PAYMENT', true),
                                            'escape' => false,
                                            'confirm' => 'Are you sure to revert payment hold?'
                                        )
                                    );
                                }
                            }
                        }
                    }
                    ?>
                    </td>
                </tr>  
                <?php
                $i++;
            }
        }
        ?>
        <tr>
            <td colspan="11" bgcolor="#ffffff" align="center">
                <div class="pagination">            
                    <?php
                    if (!empty($payableList)) {
                        echo $this->Element('pagination');
                    } else {
                        echo __("NO_RECORD_MESSAGE");
                    }
                    ?>              
                </div>
            </td>
        </tr>
    </table>
</div>
<?php echo $this->Js->writeBuffer(); ?>